/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rubric;

import java.awt.Component;
import java.util.ArrayList;

/**
 *
 * @author Jason
 */
public class RubricPanel extends javax.swing.JPanel {
    private ArrayList<ScoredDirective> directives;

    /**
     * Creates new form RubricPanel
     */
    public RubricPanel() {
        directives = new ArrayList<ScoredDirective>(0);
        initComponents();
    }
    
    public RubricPanel(String inst){
        directives = new ArrayList<ScoredDirective>(0);
        initComponents();
        instructions.setText(inst);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        jScrollPane2 = new javax.swing.JScrollPane();
        instructions = new javax.swing.JTextArea();
        directivePane = new javax.swing.JPanel();
        filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 500), new java.awt.Dimension(0, 32767));

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("(${directives.length}*50)+50"), this, org.jdesktop.beansbinding.BeanProperty.create("maximumSize"));
        bindingGroup.addBinding(binding);

        instructions.setEditable(false);
        instructions.setLineWrap(true);
        instructions.setWrapStyleWord(true);
        jScrollPane2.setViewportView(instructions);

        directivePane.setLayout(new javax.swing.BoxLayout(directivePane, javax.swing.BoxLayout.Y_AXIS));
        directivePane.add(filler1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2)
                    .addComponent(directivePane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(directivePane, javax.swing.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
                .addContainerGap())
        );

        bindingGroup.bind();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel directivePane;
    private javax.swing.Box.Filler filler1;
    private javax.swing.JTextArea instructions;
    private javax.swing.JScrollPane jScrollPane2;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the instructions
     */
    public String getInstructions() {
        return instructions.getText();
    }

    /**
     * @param instructions the instructions to set
     */
    public void setInstructions(String instruct) {
        instructions.setText(instruct);
    }

    /**
     * @return the directives
     */
    public ArrayList<ScoredDirective> getDirectives() {
        return directives;
    }

    /**
     * @param directives the directives to set
     */
    public void setDirectives(ArrayList<ScoredDirective> directives) {
        this.directives = directives;
        for (ScoredDirective d : directives){
            this.directivePane.add(new RubricDirectivePanel(d), 0);
        }
        this.validate();
    }

}
